package cn.blackjuly.cadmin.util;

import java.util.HashMap;

import org.json.JSONObject;

import com.baidu.aip.ocr.AipOcr;

public class ScannerUtil {
    //设置APPID/AK/SK
    public static final String APP_ID = "9522754";
    public static final String API_KEY = "FlRG66kmO0EHI2DNfqhc6U7w";
    public static final String SECRET_KEY = "KOaArd5GjzXGw45rGbIPMhCv4IEd5YEY";

    public static JSONObject WebImage(String imagePath){
        // 初始化一个OcrClient
        AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        // 自定义参数定义
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("language_type", "CHN_ENG");

        // 参数为本地图片路径
        JSONObject response = client.general(imagePath, options);
        return response;
    }
}